package com.masterclient.app.businessmodule.minemodule.index.animation;

import android.animation.Animator;
import android.content.Context;

import com.airbnb.lottie.LottieAnimationView;
import com.airbnb.lottie.LottieComposition;
import com.airbnb.lottie.LottieDrawable;

public class PersonAnimation {

    /**
     * 播放动画
     * */
    public void playShopAnimation(Context context, LottieAnimationView lottieAnimationView, String jsonStr) {

        lottieAnimationView.addAnimatorListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                lottieAnimationView.cancelAnimation();
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });
        LottieComposition composition = LottieComposition.Factory.fromFileSync(context, jsonStr);
        lottieAnimationView.cancelAnimation();
        lottieAnimationView.setProgress(0);
        lottieAnimationView.setRepeatCount(-1);
        lottieAnimationView.setRepeatMode(LottieDrawable.RESTART);
        lottieAnimationView.setComposition(composition);
        lottieAnimationView.playAnimation();
    }


}
